package bairui.international.model.domain.jpa;

/**
 *
 * @see TB_City 城市
 *
 */
public class TestData_TB_City
{

	private final static org.apache.commons.text.RandomStringGenerator Generator = new org.apache.commons.text.RandomStringGenerator.Builder().withinRange(new char[][]{{'a','z'}, {'A','Z'}, {'0','9'}}).build();

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_City saveMust(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_Province province
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_City");
		return (TB_City)repository.save(newMust(
				province
			));
	}
	
	public static TB_City newMust(
		bairui.international.model.domain.jpa.TB_Province province
	){
		return new TB_City(new TB_City.MustProperties() {
			/** 省份 */
			@Override public bairui.international.model.domain.jpa.TB_Province getProvince(){
				return province;
			}
			/** 名称 */
			@Override public String getName(){
				return Generator.generate(0, 20);
			}
			/** 代码 */
			@Override public String getCode(){
				return Generator.generate(0, 10);
			}
		});
	}
	

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@org.springframework.transaction.annotation.Transactional(rollbackFor=java.lang.Throwable.class)
	public static TB_City saveAll(
		org.springframework.context.ApplicationContext context,
		bairui.international.model.domain.jpa.TB_Province province
	){
		org.springframework.data.jpa.repository.JpaRepository repository = (org.springframework.data.jpa.repository.JpaRepository)context.getBean("repository_City");
		return (TB_City)repository.save(newAll(
				province
			));
	}
	
	public static TB_City newAll(
		bairui.international.model.domain.jpa.TB_Province province
	){
		return new TB_City(
			new TB_City.MustProperties() {
				/** 省份 */
				@Override public bairui.international.model.domain.jpa.TB_Province getProvince(){
					return province;
				}
				/** 名称 */
				@Override public String getName(){
					return Generator.generate(0, 20);
				}
				/** 代码 */
				@Override public String getCode(){
					return Generator.generate(0, 10);
				}
			},
			new TB_City.OptionalSingleProperties() {
			}
		);
	}
	

}
